package com;

import java.util.ArrayList;
import java.util.List;

public class HeapOOM {
    static class OOM{

    }

    /**
     * -Xms10m -Xmx10m -XX:+HeapDumpOnOutOfMemoryError
     * -XX:+HeapDumpOnOutOfMemoryError 让虚拟机在出现内存溢出异常时Dump出当前的内存堆转储快照
     * @param args
     */
    public static void main(String[] args) {
        /*
            java.lang.OutOfMemoryError: Java heap space
            Dumping heap to java_pid9368.hprof ...
            Heap dump file created [28275886 bytes in 0.140 secs]
         */
        List<OOM> list=new ArrayList<>();
        while (true){
            list.add(new OOM());
        }
    }
}

